package com.zzx.controller;

import com.zzx.service.PermissionService;
import com.zzx.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    /**
     * 获取每个角色的权限信息
     * @return
     */
//    @PreAuthorize("hasAuthority('权限列表')")
    @GetMapping("/menus")
    public ResponseResult menus(){
        return permissionService.menus();
    }

    /**
     *
     * @param type
     * @return
     */
    @PreAuthorize("hasAuthority('权限列表')")
    @GetMapping("/rights/{type}")
    public ResponseResult RightsList(@PathVariable("type") String type){
        return permissionService.RightsList(type);
    }

}
